﻿using DAL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WxPayAPI;

namespace WeChat
{
    public partial class qy : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {


            H5Pay h5Pay = new H5Pay();
            string scip = GetIP();//获取客户端真实IP
            string Opid = "jsldfowoeroislkdjfwoie";
            ApplicationLog.Write("scip=" + scip);
            string url = h5Pay.GetPayUrl(scip, Opid, "1");//通过统一下单接口进行H5支付
            Response.Redirect(url);




        }

        public string GetIP()
        {
            HttpRequest request = HttpContext.Current.Request;
            string result = request.ServerVariables["HTTP_X_FORWARDED_FOR"];
            if (string.IsNullOrEmpty(result))
            {
                result = request.ServerVariables["REMOTE_ADDR"];
            }
            if (string.IsNullOrEmpty(result))
            {
                result = request.UserHostAddress;
            }
            if (string.IsNullOrEmpty(result))
            {
                result = "0.0.0.0";
            }
            return result;
        }
    }
}